<!--
 * Description: PBM报价修改组件
 * Company: 联宝（合肥）电子科技有限公司
 * Author: Qiuxue.Wu
 * Date: 2020/06/1 14:30
-->

<template>
  <div>
    <!--数据表单-->
    <el-form label-width="150px" :model="formData" size="mini">
      <el-row>
        <!--行号-->
        <el-col :span="12">
          <el-form-item :label="$t('FdData.currentRowNo')">
            <span>{{ currentRowNo }}</span>
          </el-form-item>
        </el-col>

        <!--GCM Cost-->
        <!-- <el-col :span="12">
          <el-form-item :label="$t('FdData.gcmCost')">
            <span>{{ formData.gcmCost }}</span>
          </el-form-item>
        </el-col> -->

        <!--SAP Standard Price-->
        <el-col :span="12">
          <el-form-item :label="$t('FdData.baseSapStandardPrice')">
            <span>{{ formData.baseSapStandardPrice }}</span>
          </el-form-item>
        </el-col>

        <!--SAP 采购价-->
        <el-col :span="12">
          <el-form-item :label="$t('FdData.baseSapPurchasePrice')">
            <span>{{ formData.baseSapPurchasePrice }}</span>
          </el-form-item>
        </el-col>

        <!--Recently Quote-->
        <!-- <el-col :span="12">
          <el-form-item :label="$t('FdData.recentlyQuote')">
            <span>{{ formData.recentlyQuote }}</span>
          </el-form-item>
        </el-col> -->

        <!--pbmCost-->
        <el-col :span="24">
          <el-form-item :label="$t('FdData.pbmCost')">
            <el-input v-model="formData.pbmCost" v-precision:pbmCost.n0="formData" type="number" />
          </el-form-item>
        </el-col>

        <!--pbmCommitCost-->
        <el-col :span="24">
          <el-form-item :label="$t('FdData.pbmCommitCost')">
            <el-input
              v-model="formData.pbmCommitCost"
              v-precision:pbmCommitCost="formData"
              type="number"
            />
          </el-form-item>
        </el-col>

        <!--costDown-->
        <el-col :span="24">
          <el-form-item :label="$t('ecdfc.costDown')">
            <el-input v-model="formData.costDown" v-precision:costDown="formData" type="number" />
          </el-form-item>
        </el-col>

        <!--tecDelta-->
        <!-- <el-col :span="24">
          <el-form-item :label="$t('FdData.tecDelta')">
            <el-input v-model="formData.tecDelta" v-precision:tecDelta="formData" type="number" />
          </el-form-item>
        </el-col> -->

        <!--aucDelta-->
        <!-- <el-col :span="24">
          <el-form-item :label="$t('FdData.aucDelta')">
            <el-input v-model="formData.aucDelta" v-precision:aucDelta="formData" type="number" />
          </el-form-item>
        </el-col> -->
      </el-row>
    </el-form>
    <span style="display: block;text-align: center;margin-top: 5px">
      <!--取消按钮-->
      <el-button size="medium" @click="cancel">{{ $t('button.cancel') }}</el-button>
      <!--保存按钮-->
      <el-button :loading="isRequesting" size="medium" type="primary" @click="save">
        {{ $t('button.save') }}
      </el-button>
    </span>
  </div>
</template>

<script>
import { fdQuote } from '@/api/ecdfc/fd'

export default {
  name: 'EcQuoteEdit',
  props: {
    inputData: {
      type: Object,
      default() {
        return {}
      }
    },
    currentRowNo: {
      type: Number,
      default: 0
    }
  },
  data() {
    return {
      // 正在查询
      isRequesting: false,
      formData: null
    }
  },
  created() {
    this.pageDataInit()
  },
  methods: {
    pageDataInit() {
      this.formData = this.$deepCopy(this.inputData)
    },
    async save() {
      try {
        this.isRequesting = true
        await fdQuote(
          {
            pbmCost: this.formData.pbmCost,
            pbmCommitCost: this.formData.pbmCommitCost,
            fdRowId: this.formData.fdRowId,
            costDown: this.formData.costDown
          },
          { msgSuccess: true, msgError: true }
        )
        this.$emit('save', this.formData)
      } catch (error) {
        console.log(error)
      } finally {
        this.isRequesting = false
      }
    },
    cancel() {
      this.$emit('cancel')
    }
  }
}
</script>

<style scoped>
.el-form-item__content span {
  margin-left: 5px;
  color: blue;
}
</style>
